import java.text.BreakIterator;

/**
 * Created by IntelliJ IDEA.
 * User: James Barker
 * Date: 2/08/11
 * Time: 3:58 PM
 * To change this template use File | Settings | File Templates.
 */
public class ElevatorController {

    int minFloor;
    int maxFloor;
    Elevator e;

    public ElevatorController(int minFloor, int maxFloor) {
        this.minFloor = minFloor;
        this.maxFloor = maxFloor;
        e = new Elevator(maxFloor);
    }

    public int getMinFloor() {
        return minFloor;
    }

    public int getMaxFloor() {
        return maxFloor;
    }

    public void moveElevator(int destinationFloor) {
        while (true) {
            try{
                Thread.sleep(1000);

                System.out.println("(((  >>  " + e.getCurrentFloor() + "  <<  )))");

                if (e.getCurrentFloor() == destinationFloor) {
                    System.out.println("<<<<<     SAME FLOOR     >>>>>");
                    break;
                }
                else if (e.getCurrentFloor() < destinationFloor) {
                    System.out.println("<<<<<     MOVING UP     >>>>>");
                    e.setCurrentFloor(e.getCurrentFloor() + 1);
                }
                else if (e.getCurrentFloor() > destinationFloor) {
                    System.out.println("<<<<<     MOVING DOWN     >>>>>");
                    e.setCurrentFloor(e.getCurrentFloor() - 1);
                }
                else {
                    System.out.println("WE GOT PROBLEMS RIGHT HERE MATE!!!");
                    break;
                }
            } catch (Exception e) {

            }
        }
    }
}
